package com.zy.project1.aspects;

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @program: mavenTest153
 * @description:
 * @author: zy
 * @create: 2025-07-15 10:18
 */
@Aspect   //这是一个切面类
@Component  //将切面类交给Spring管理
@Order(value=100)
public class MyAspects {
   //对addBankAccount操作前，进行权限验证.
    @Pointcut("execution(* com.zy.project1.biz.*.add*(..))")

    public void qx() {}

    @Before("qx()")

    public void doAccessCheck() {
       System.out.println("===================");
        System.out.println("权限验证通过");
        System.out.println("===================");
    }

    @Pointcut("execution(* com.zy.project1.biz.*.show*(..))")
    public void show(){}
    @Pointcut("execution(* com.zy.project1.biz.*.find*(..))")
    public void find(){}
    @Pointcut("execution(* com.zy.project1.biz.*.get*(..))")
    public void getThing(){}

    //spring DI
    @AfterReturning( value="show()||find()||getThing()", returning="retVal")
    public void doLog(   Object retVal){
        System.out.println("===================");
        System.out.println("记录日志,查询到的结果:"+ retVal.toString());
        System.out.println("===================");
    }






}
